package com.daqsoft.dao;

import com.daqsoft.data.Permission;
import com.daqsoft.dto.PermissionTypeEnum;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * 权限数据层
 * @author 周麟东 on 14:22
 */
@Repository
public interface PermissionDao extends JpaRepository<Permission,Integer> {
    List<Permission> findPermissionByGroupIdAndType(int groupId,PermissionTypeEnum type);
    void deletePermissionsByGroupIdAndType(int groupId , PermissionTypeEnum type);
    @Query("select count (t) from  Permission t where t.configId in :configId and t.groupId = :groupId")
    int countPermissionByEngineId(@Param("configId") int configId[],@Param("groupId") int groupId);
}
